Repository navigation
Stop following redirects, so the key never goes to the host they name - #36
Merged
Merged
Conversation
urlopen follows 301/302/303 by re-sending the Authorization header to the Location target as an empty GET. Reports now go through an opener whose redirect handler declines every redirect, so the 3xx reaches the existing non-201 DEBUG line with its own status, as trace-client-java does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (scored against the diff and command output; one intrinsic pass):
Judgment call for the owner:
Merge gate: wire-format change ( This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_sendnow opens each report through a module-level opener (_OPENER) whoseHTTPRedirectHandlerdeclines every redirect, in place ofurllib.request.urlopen. A301/302/303no longer re-sendsAuthorization: Bearer <key>to theLocationhost as an emptyGET; every3xxreaches the existing non-201DEBUG line with its own status (answered 302) and the report is dropped.install_openerwas deliberately not used: it would changeurlopenfor the whole host program.Closes #31
Test plan
test_a_redirect_is_logged_and_dropped_never_followed_with_the_keycovers 301, 302, 303, 307 and 308. The origin redirects to a second loopback server reached aslocalhoston another port. The test asserts that the target receives nothing and that the log names the redirect status at DEBUG.trace_client.pychange stashed, the new test fails becauseGET /elsewherereached the other host with the key. With the change restored, it passes.test_an_error_answer_whose_body_cannot_be_read_still_logs_its_statusnow patches_OPENER.openinstead ofurllib.request.urlopen, becauseurlopenis no longer the call path. Its assertions are unchanged.python3 -m unittest(Python 3.8.10): Ran 73 tests, OK.HTTPRedirectHandler, so the 3.12 job is the check for that row.Java parity
This brings Python in line with trace-client-java, which by its README already does not follow redirects. No Java change is needed. The Java README could not be re-read from this session's sandbox, so the parity claim relies on the quotation verified when #31 was filed.
Merge gate
This PR changes
_send's behaviour on the wire, which is on this loop's do-not-auto-merge list (wire format must stay in lockstep with trace-client-java and the trace server). It is left open for owner review rather than merged autonomously, as #31 itself requested.Deferred
MAX_TAGS) was not picked up. It still needs an owner decision on the README promise thattags"always holds at leastversion", and a change made in step with trace-client-java (see the comment on The version tag is added even when it pushes an event past MAX_TAGS #16).This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson